package com.navinfo.opentsp.platform.computing.dto;


import com.navinfo.opentsp.platform.computing.util.EntityConvert;
import com.navinfo.opentsp.platform.location.protocol.common.LCPredictiveMaintenance;

public class MaintenanceEvent2Dto {
    private double mileage;           //里程
    private double speed;             //车速
    private int clutchSwitch;         //离合器开关
    private int neutralSwitch;        //空挡开关
    private long engineTorque;        //发动机扭矩
    private long flywheelTorque;      //飞轮扭矩
    private double rotation;          //发动机转速
    private int   energyType4;       //转速差
    private double synchronisedTime4;  //同步时间（s）
    private long	energyValue4;	//能量值（J）
    private double	rotationDifference4;	 //转速差（rpm）
    private int	   gearPosition4;	//档位
    private double	clutchDisplacement5;	//离合器位移初始值（mm）
    private double	clutchRealTimeDisplacement5;	//离合器位移实时位移值（mm）
    private int	    quality5;	            //质量（kg）
    private int	    ramp5;	 //坡道(百分比)
    private int	    clutchPressurePlateTemperature5;	//离合器压盘温度(摄氏度)



    public double getMileage() {
        return mileage;
    }

    public void setMileage(double mileage) {
        this.mileage = mileage;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public int getClutchSwitch() {
        return clutchSwitch;
    }

    public void setClutchSwitch(int clutchSwitch) {
        this.clutchSwitch = clutchSwitch;
    }

    public int getNeutralSwitch() {
        return neutralSwitch;
    }

    public void setNeutralSwitch(int neutralSwitch) {
        this.neutralSwitch = neutralSwitch;
    }

    public long getEngineTorque() {
        return engineTorque;
    }

    public void setEngineTorque(long engineTorque) {
        this.engineTorque = engineTorque;
    }

    public long getFlywheelTorque() {
        return flywheelTorque;
    }

    public void setFlywheelTorque(long flywheelTorque) {
        this.flywheelTorque = flywheelTorque;
    }

    public double getRotation() {
        return rotation;
    }

    public void setRotation(double rotation) {
        this.rotation = rotation;
    }

    public int getEnergyType4() {
        return energyType4;
    }

    public void setEnergyType4(int energyType4) {
        this.energyType4 = energyType4;
    }

    public double getSynchronisedTime4() {
        return synchronisedTime4;
    }

    public void setSynchronisedTime4(double synchronisedTime4) {
        this.synchronisedTime4 = synchronisedTime4;
    }

    public long getEnergyValue4() {
        return energyValue4;
    }

    public void setEnergyValue4(long energyValue4) {
        this.energyValue4 = energyValue4;
    }

    public double getRotationDifference4() {
        return rotationDifference4;
    }

    public void setRotationDifference4(double rotationDifference4) {
        this.rotationDifference4 = rotationDifference4;
    }

    public int getGearPosition4() {
        return gearPosition4;
    }

    public void setGearPosition4(int gearPosition4) {
        this.gearPosition4 = gearPosition4;
    }


    public int getQuality5() {
        return quality5;
    }

    public void setQuality5(int quality5) {
        this.quality5 = quality5;
    }

    public int getRamp5() {
        return ramp5;
    }

    public void setRamp5(int ramp5) {
        this.ramp5 = ramp5;
    }

    public double getClutchDisplacement5() {
        return clutchDisplacement5;
    }

    public void setClutchDisplacement5(double clutchDisplacement5) {
        this.clutchDisplacement5 = clutchDisplacement5;
    }

    public double getClutchRealTimeDisplacement5() {
        return clutchRealTimeDisplacement5;
    }

    public void setClutchRealTimeDisplacement5(double clutchRealTimeDisplacement5) {
        this.clutchRealTimeDisplacement5 = clutchRealTimeDisplacement5;
    }

    public int getClutchPressurePlateTemperature5() {
        return clutchPressurePlateTemperature5;
    }

    public void setClutchPressurePlateTemperature5(int clutchPressurePlateTemperature5) {
        this.clutchPressurePlateTemperature5 = clutchPressurePlateTemperature5;
    }

    public static MaintenanceEvent2Dto parseProto(LCPredictiveMaintenance.MaintenanceEvent2 maintenanceEvent2){
        MaintenanceEvent2Dto maintenanceEvent2Dto = new MaintenanceEvent2Dto();
        maintenanceEvent2Dto.setMileage(maintenanceEvent2.getMileage());
        maintenanceEvent2Dto.setSpeed(maintenanceEvent2.getSpeed());
        maintenanceEvent2Dto.setClutchSwitch(maintenanceEvent2.getClutchSwitch());
        maintenanceEvent2Dto.setNeutralSwitch(maintenanceEvent2.getNeutralSwitch());
        maintenanceEvent2Dto.setEngineTorque(maintenanceEvent2.getEngineTorque());
        maintenanceEvent2Dto.setFlywheelTorque(maintenanceEvent2.getFlywheelTorque());
        maintenanceEvent2Dto.setRotation(maintenanceEvent2.getRotation());
        maintenanceEvent2Dto.setEnergyType4(maintenanceEvent2.getEnergyType4());
        maintenanceEvent2Dto.setSynchronisedTime4(maintenanceEvent2.getSynchronisedTime4());
        maintenanceEvent2Dto.setEnergyValue4(maintenanceEvent2.getEnergyValue4());
        maintenanceEvent2Dto.setRotationDifference4(maintenanceEvent2.getRotationDifference4());
        maintenanceEvent2Dto.setGearPosition4(maintenanceEvent2.getGearPosition4());
        maintenanceEvent2Dto.setClutchDisplacement5(maintenanceEvent2.getClutchDisplacement5());
        maintenanceEvent2Dto.setClutchRealTimeDisplacement5(maintenanceEvent2.getClutchRealTimeDisplacement5());
        maintenanceEvent2Dto.setQuality5(maintenanceEvent2.getQuality5());
        maintenanceEvent2Dto.setRamp5(maintenanceEvent2.getRamp5());
        maintenanceEvent2Dto.setClutchPressurePlateTemperature5(maintenanceEvent2.getClutchPressurePlateTemperature5());
        return maintenanceEvent2Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEvent2
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEvent2 maintenanceEvent2){
        return EntityConvert.convert(
                maintenanceEvent2.getMileage(),
                maintenanceEvent2.getSpeed(),
                maintenanceEvent2.getClutchSwitch(),
                maintenanceEvent2.getNeutralSwitch(),
                maintenanceEvent2.getEngineTorque(),
                maintenanceEvent2.getFlywheelTorque(),
                maintenanceEvent2.getRotation(),
                maintenanceEvent2.getEnergyType4(),
                maintenanceEvent2.getSynchronisedTime4(),
                maintenanceEvent2.getEnergyValue4(),
                maintenanceEvent2.getRotationDifference4(),
                maintenanceEvent2.getGearPosition4(),
                maintenanceEvent2.getClutchDisplacement5(),
                maintenanceEvent2.getClutchRealTimeDisplacement5(),
                maintenanceEvent2.getQuality5(),
                maintenanceEvent2.getRamp5(),
                maintenanceEvent2.getClutchPressurePlateTemperature5());

    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEvent2 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEvent2.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=17){
                builder =LCPredictiveMaintenance.MaintenanceEvent2.newBuilder();
                builder.setMileage(Double.valueOf(revert[0]));
                builder.setSpeed(Double.valueOf(revert[1]));
                builder.setClutchSwitch(Integer.valueOf(revert[2]));
                builder.setNeutralSwitch(Integer.valueOf(revert[3]));
                builder.setEngineTorque(Long.valueOf(revert[4]));
                builder.setFlywheelTorque(Long.valueOf(revert[5]));
                builder.setRotation(Double.valueOf(revert[6]));
                builder.setEnergyType4(Integer.valueOf(revert[7]));
                builder.setSynchronisedTime4(Double.valueOf(revert[8]));
                builder.setEnergyValue4(Long.valueOf(revert[9]));
                builder.setRotationDifference4(Double.valueOf(revert[10]));
                builder.setGearPosition4(Integer.valueOf(revert[11]));
                builder.setClutchDisplacement5(Double.valueOf(revert[12]));
                builder.setClutchRealTimeDisplacement5(Double.valueOf(revert[13]));
                builder.setQuality5(Integer.valueOf(revert[14]));
                builder.setRamp5(Integer.valueOf(revert[15]));
                builder.setClutchPressurePlateTemperature5(Integer.valueOf(revert[16]));
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }

}
